package com.mvp.shq.washer.ui.shop.category;

import com.mvp.shq.washer.entity.result.BaseResult;
import com.mvp.shq.washer.entity.shop.Category;
import com.mvp.shq.washer.http.BaseObserver;
import com.mvp.shq.washer.utils.T;

import java.util.List;

/**
 * Created by shq1 on 2017/9/30.
 */

public class Presenter extends CategoryConstract.Presenter {
    @Override
    public void onStart() {

    }

    @Override
    void getCategory() {
        model.getCategory()
                .compose(getActivityLifecycleProvider().bindToLifecycle())
                .subscribe(new BaseObserver<List<Category>>(view) {
                    @Override
                    protected void onSuccees(BaseResult<List<Category>> t) throws Exception {
                        if (t.isError()){
                            T.show(t.getMsg());
                        }else {
                            view.getCategoryS(t.getData());
                        }
                    }

                    @Override
                    protected void onFailure(Throwable e, boolean isNetWorkError) throws Exception {
                        T.show(e.getMessage());
                        e.printStackTrace();
                    }
                });
    }
}
